package com.cwvs.cat;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;

import com.cwvs.cat.fragment.SchoolMateInviteActiveFragment;
import com.cwvs.cat.fragment.SchoolMateInviteClubFragment;

public class MyFriendSchoolMateInviteActivity extends FragmentActivity {
	
	private ImageView img_select_club,img_select_active;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_my_friend_school_mate_invite);
		initView();
	}

	private void initView(){
		img_select_active=(ImageView) this.findViewById(R.id.img_select_active);
		img_select_active.setOnClickListener(clubOnClickListener);
		img_select_club=(ImageView) this.findViewById(R.id.img_select_club);
		img_select_club.setOnClickListener(myFriendOnClickListener);
		
		img_select_active.performClick();
	}

	
	private OnClickListener clubOnClickListener=new OnClickListener() {
		@Override
		public void onClick(View v) {
			clearSelection();
			img_select_active.setImageResource(R.drawable.select_active_blue);
			img_select_active.setEnabled(false);
			FragmentManager fm=getSupportFragmentManager();
			FragmentTransaction ft=fm.beginTransaction();
			SchoolMateInviteActiveFragment activeFragment=new SchoolMateInviteActiveFragment();
			ft.replace(R.id.linear_invate_contact, activeFragment,MainActivity.TAG);
			ft.commit();

		}
	};

	private OnClickListener myFriendOnClickListener=new OnClickListener() {
		@Override
		public void onClick(View v) {
			clearSelection();
			img_select_club.setImageResource(R.drawable.select_club_blue);
			img_select_club.setEnabled(false);
			FragmentManager fm=getSupportFragmentManager();
			FragmentTransaction ft=fm.beginTransaction();
			SchoolMateInviteClubFragment clubFragment=new SchoolMateInviteClubFragment();
			ft.replace(R.id.linear_invate_contact, clubFragment,MainActivity.TAG);
			ft.commit();
			
		}
	};

	private void clearSelection() {
		img_select_active.setImageResource(R.drawable.select_active_white);
		img_select_active.setEnabled(true);
		img_select_club.setImageResource(R.drawable.select_club_white);
		img_select_club.setEnabled(true);

	}


}
